home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / eulisp / mpfeel.lha / MPFeel / Plurals / proto.h < prev    next >
C/C++ Source or Header  |  1992-04-27  |  3KB  |  123 lines

  1. /******************************************************************************
  2.  
  3.    Allow source code to be compiled with both ANSI and K&R compilers.
  4.  
  5.    Copyright 1991,1992 Lee Iverson
  6.  
  7.    Author:
  8.      Lee Iverson <leei@mcrcim.mcgill.edu>,
  9.      McGill Research Centre for Intelligent Machines (McRCIM)
  10.  
  11.    See <McImage/copyright.h> for complete copyright information.
  12.  
  13.    $Id: proto.h,v 1.3 92/02/06 15:47:05 leei Exp $
  14.  
  15.    Usage: By conforming to the standard declaration style suggested
  16.      herein, one can create source which will compile properly under
  17.      both K&R and ANSI C implementations.  I hope that the
  18.      macros don't inhibit readability too much.
  19.  
  20.    * Function declaration (e.g. forward or extern declarations.)
  21.  
  22.      extern int foo __((float a, float b));
  23.     - or -
  24.      extern int foo _DCL((a), float a _AND float b);
  25.     - or -
  26.      extern int foo _D((a), float a _AND float b);
  27.  
  28.      Void functions are handled specially:
  29.  
  30.      extern int foo __((void));
  31.     - or -
  32.      extern int foo _DCL_VOID();
  33.     - or -
  34.      extern int foo _DVOID();
  35.  
  36.    * Function implementation.
  37.  
  38.      int foo _IMPL((a), float a _AND float b)
  39.     - or -
  40.      int foo _I((a), float a _AND float b)
  41.      {
  42.          ...
  43.      }
  44.  
  45.      Void functions are handled specially:
  46.  
  47.      extern int foo _IMPL_VOID()
  48.     - or -
  49.      extern int foo _IVOID()
  50.      {
  51.          ...
  52.      }
  53.  
  54.    * Token concatenation (useful in constructive macros).
  55.  
  56.      CONCAT(a_,b) => a_b
  57.      CONCAT3(a_,b,_c) => a_b_c
  58.  
  59.    * Stringify (only valid inside a macro expansion).
  60.  
  61.      STRING(foo) => "foo"
  62.  
  63.    * New keywords in ANSI have no effect in K&R! (e.g. const, volatile)
  64.    
  65. ******************************************************************************/
  66.  
  67. #ifndef _proto_h_
  68. #define _proto_h_
  69.  
  70. # if defined(__STDC__) || defined(__STDMPL__)
  71.  
  72. #  ifndef __
  73. #   define __(x) x
  74. #  endif
  75. #  ifndef _DCL
  76. #   define _DCL(args, dcls)    (dcls)
  77. #   define _DCL_VOID()        (void)
  78. #   define _IMPL(args, dcls)    (dcls)
  79. #   define _IMPL_VOID()        (void)
  80.  
  81. #   define _D(args, dcls)    (dcls)
  82. #   define _DVOID()        (void)
  83. #   define _I(args, dcls)    (dcls)
  84. #   define _IVOID()        (void)
  85.  
  86. #   define _AND ,
  87. #  endif
  88.  
  89. #  define CONCAT(x,y)     x##y
  90. #  define CONCAT3(x,y,z) x##y##z
  91. #  define STRING(x)     #x
  92.  
  93. # else
  94.  
  95. #  ifndef __
  96. #   define __(x) ()
  97. #  endif
  98. #  ifndef _DCL
  99. #   define _DCL(args, dcls)    ()
  100. #   define _DCL_VOID()        ()
  101. #   define _IMPL(args, dcls)    args dcls;
  102. #   define _IMPL_VOID()        ()
  103.  
  104. #   define _D(args, dcls)    ()
  105. #   define _DVOID()        ()
  106. #   define _I(args, dcls)    args dcls;
  107. #   define _IVOID()        ()
  108.  
  109. #   define _AND ;
  110. #  endif
  111.  
  112. #  define signed
  113. #  define const
  114. #  define volatile
  115.  
  116. #  define CONCAT(x,y)     x/**/y
  117. #  define CONCAT3(x,y,z) x/**/y/**/z
  118. #  define STRING(x)     "x"
  119.  
  120. # endif /* __STDC__ */
  121.  
  122. #endif /* _proto_h_ */
  123.